<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>设备效率</title>
	
	<script type="text/javascript">
		function highEffect(currPage) {
			$.ajax({
				type: 'post',
				url: 'log/getDeviceHighEffect.action',
				data: {
					currPage: currPage
				},
				success: function(data) {
					$("#effect_show").html(data);
				}
			});
		}
		function lowEffect(currPage) {
			$.ajax({
				type: 'post',
				url: 'log/getDeviceLowEffect.action',
				data: {
					currPage: currPage
				},
				success: function(data) {
					$("#effect_show").html(data);
				}
			});
		}
		function selectByNum() {
			var keyword = $("#keyword").val();
			$.ajax({
				type: 'post',
				url: 'log/selectByNum.action',
				data: {
					keyword: keyword
				},
				success: function(data) {
					$("#effect_show").html(data);
					$("#keyword").val(keyword);
				}
			});
		}
		
	</script>
</head>

<body>
	<div>
		<h2><a href="javascript:void(0);" onclick="device_effect(1);">设备效率</a></h2>
		<div style="width: 600px; display: inline-block; float: left;">
			<div style="width:280px; display: inline-block; float: right; margin-bottom: 3px;">
				<div style="width: 200px; display: inline-block;">
					<input id="keyword" class="form-control"  type="text" placeholder="请输入设备编号" />
				</div>
				<button class="btn" onclick="selectByNum();">查询</button>
			</div>
			<div id="effect_show">
			<table class="table	table-bordered">
			<thead>
				<tr>
					<th>序号</th>
					<th>设备编号</th>
					<th>工作时间(h)</th>
					<th>故障时间(h)</th>
					<th>工作效率(%)</th>
				</tr>
			</thead>
			<tbody>	
				<c:if test="${list != null}">		
				<%  int num = (Integer)request.getAttribute("currPage");
	    			int i= (num-1)*5; %>
				<c:forEach items="${list}" var="item"> 
				<tr> 
					<% i++; %>
	    			<td><%= i %></td>
					<td>${item.deviceNum}</td>
					<td>${item.worktime}</td>
					<td>${item.errortime}</td>
					<td>${item.effect}</td>
				</tr>
				</c:forEach>
				</c:if>
			</tbody>
			<tfoot>
	            <tr>
	                <td colspan="5">
	                <div class="pagination">
	    			<a href="javascript:void(0);" onclick="device_effect(1)">第一页</a>
	    			<a href="javascript:void(0);" onclick="device_effect(${currPage-1})">上一页</a>
	    			<a href="javascript:void(0);" onclick="device_effect(${currPage+1})">下一页</a>
	    			<a href="javascript:void(0);" onclick="device_effect(${totalPage})">最末页</a>
	    			${currPage}/${totalPage}页,共${totalRows}个项目
	    			</div>
	    			</td>
	            </tr>
	        </tfoot>
			</table>
			</div>
		</div>
		<div style="display: inline-block; float: left; margin-left: 20px; padding-top: 50px;">
			<p><button class="btn" onclick="highEffect()">设备效率大于90%</button></p>
			<p><button class="btn" onclick="lowEffect()">设备效率小于90%</button></p>
		</div>
	</div>
</body>
</html>